<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="../../attr.jsp" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE html>
<html>
<head>
<title>物品回收管理</title>
<script type="text/javascript" src="${ctx}/js/kkpager.min.js"></script>
<link rel="stylesheet" type="text/css" href="${ctx}/css/kkpager_blue.css" />
</head>
<body>
 <form  method="post" id="dataForm" name="dataForm">
  <div id="main">
    <!-- Start: Header -->
    <header class="navbar bg-primary navbar-fixed-top">
    </header>
    <!-- End: Header -->
    <!-- Start: Sidebar -->
    <aside id="sidebar_left" class="nano nano-primary affix sidebar-light">
    </aside>
    <!-- end: Sidebar -->
   
    <!-- Start: Content-Wrapper -->
    <section id="content_wrapper">
 
      <!-- Start: Topbar -->
      <header id="topbar" class="affix">
        <div class="topbar-left">
          <ol class="breadcrumb">
            <li class="crumb-active">
              <a href="#">物品回收管理</a>
            </li>
            <li class="crumb-link">
              <a href="#">回收管理</a>
            </li>
          </ol>
        </div>
      </header>
      <!-- End: Topbar -->

      <!-- Begin: Content -->
      <section id="content" class="table-layout">
		 <!--start 内容-->	
		
        <!-- begin: .tray-center -->
        <div style="height: 619px;" class="tray tray-center">

          <!-- recent orders table -->
          <div class="panel">
            <div class="panel-menu p12 admin-form theme-primary">
              <div class="row">
				
				<div class="col-xs-18">
				  <p class="text-right">
					<button type="button" id="bac" class="btn active btn-danger" style="margin-right:10px;" >回收</button>
					<button type="button" id="save" class="btn active btn-success">确认回收</button>
				  </p>
				</div>	
              </div>
            </div>
            <div class="panel-body pn">
            <table class="table table-bordered admin-form theme-warning tc-checkbox-1 fs13">
              <tr>
                <td>
                 <div class="table-responsive">
	                <table class="table table-bordered admin-form theme-warning tc-checkbox-1 fs13" id="tpaTable">
	                  <thead>
	                    <tr class="bg-light">
	                      <th class="text-left">科室</th>
	                      <th class="text-left">包名称</th>
	                      <th class="text-left">包数量</th>
	                    </tr>
	                  </thead>
	                  <tbody>
	                  	 
	                  </tbody>
	                </table>
	              </div>
                </td>
              </tr>
            </table>
             
            </div>
           
            <br/>
            <div  class="tab-content pn br-n admin-form">
	            <div class="section row">
			 	<div class="col-md-12">
					<div class="section mb12">
					  选择网篮
	                     <label class="field select">
	                       <select class="empty" id="wanglan" name="wanglan">
	                         	<c:if test="${wanglanList !=null }">
	                        	<c:forEach items="${wanglanList }" var="tdt">
	                       			<option value="${tdt.wlTiaoma}" >${tdt.wlMingcheng}</option>
	                       		</c:forEach>
	                        </c:if>
	                       </select>
	                       <i class="arrow double"></i>
	                     </label>
					</div>
	            </div>
	            
	            <div class="col-md-12">
					<div class="section mb10">
					  丢失物品备注
					  	<label class="field prepend-icon">
                          <textarea style="height: 160px;" class="gui-textarea br-light light" id="hsMark" name="hsMark" placeholder="包缺失物品，请备注"></textarea>
                          <label for="packageText" class="field-icon">
                            <i class="fa fa-comments"></i>
                          </label>
                        </label>
	                      
					</div>
	            </div>
	            
			    </div>
             
            </div>
            
          </div>
         
		 
        </div>
        <!-- end: .tray-center -->
		 
		 <!-- end 内容-->
      </section>
      <!-- End: Content -->
	  <!-- Begin: Page Footer -->
      <footer id="content-footer" class="affix">
        <div class="row">
          <div class="col-md-6">
            <span class="footer-legal">雷软科技有限公司 @2016 版权所有</span>
          </div>
          <div class="col-md-6 text-right">
            <span class="footer-meta">服务支持热线：17771741330</span>
            <a href="#content" class="footer-return-top">
              <span class="fa fa-arrow-up"></span>
            </a>
          </div>
        </div>
      </footer>
      <!-- End: Page Footer -->
    </section>
  </div>
  </form>
  <!-- End: Main -->
	<script src="${ctx}/js/utility.js"></script>
	<script src="${ctx}/js/main.js"></script> 
	<script src="${ctx}/js/demo.js"></script>  
  <script type="text/javascript">
  	function getParameter(name) { 
		var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)"); 
		var r = window.location.search.substr(1).match(reg); 
		if (r!=null) return unescape(r[2]); return null;
	}
	function do_bac(){
		layer.open({
			type: 2,
			title: '无条码包回收登记',
			maxmin: true,
			shadeClose: true, //点击遮罩关闭层
			area : ['800px' , '520px'],
			content: '${ctx}/zsHuiShou/bac.do'
		});
	}
	
	function getSelRecord(){
		var chk_value =[];
	   $('input[name="key"]:checked').each(function(){
			chk_value.push($(this).val()); 
		});
		return chk_value;
	}  
  
	//{depart:,package:,num:}
	function callbackData(data){
		//$("#tpaTable tbody").empty();
		console.log(data);
		var str = '';
		for(var i = 0;i<data.length;i++){
			str += checkstr(data[i]);
		}
		$("#tpaTable tbody").append(str);
	}
	//
	function checkstr(data){
		var obj = $("#" + data.depId+'_'+data.packId);
		console.log("id:"+obj);
		if(obj.length>0){
			//修改行之为数量 然后返回""
			var sum_pre = $("#"+data.packId).val();
			sum_next = parseInt(sum_pre) +  parseInt(data.packNum);
			$("#"+data.packId).val(sum_next);
			return "";
		}else{
			return '<tr id="'+data.depId+'_'+data.packId+'"><td class="text-left">'+data.depVal+'</td><td class="text-left">'+data.packName+'</td><td class="text-left"><input type="hidden" name="packId" value="'+data.packId+'"/><input type="text"  class="gui-input" name="packNum"  id="'+data.packId+'" value="'+data.packNum+'"/></td></tr>'; 
		}
	}
	
  jQuery(document).ready(function() {
    "use strict";   
    Core.init();  
    Demo.init();
	/////////////////////////
 	$("#bac").click(function(){
 		do_bac();
 	});
 	$("#save").click(function(){
//  	$('input[name="packNum"]').each(function(){
// 			alert($(this).val()); 
// 		})
 		
		$.ajax({
            type: "POST",
            url:"${ctx}/zsHuiShou/save.do",
            data:$('#dataForm').serialize(),// 你的formid
            error: function(request) {
           	 layer.alert("网络故障，请稍后再试!");
            },
            success: function(data) {
           	 if(data.status=="true"){
           		 layer.alert("回收成功,点击确定继续回收", function(index){
           			  window.location.href="${ctx}/zsHuiShou/findAllHuiShouList.do";
           		});
           	 }else{
           		 
           	 }
            }
        });
 	});
	
  });
  
 
  </script>
  </body>
</html>
